﻿package com.saint.bitmapDistortion.tests 
{
	import com.saint.utils.Logger;
	import com.saint.utils.BitmapUtils;
	import com.saint.utils.TileMaker;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.utils.getTimer;
	/**
	 * ...
	 * @author kembera
	 */
	public class ImageCropTest extends Sprite
	{
		private var sourceBitmapData:BitmapData = new GoatBitmapData(0, 0);
		
		private var origionalBitmap:Bitmap 
		private var goat = new Goat();
		
		croppedBitmap:Bitmap;
		
		
		
		
		
		public function ImageCropTest() 
		{
			Logger.info("imageCroptest");
			Logger.debug("imageCroptest source bitmap dimensions: " + sourceBitmapData.width + ",  " + sourceBitmapData.height)
			
			//addChild(goat);		
			
			var cols:Number = 2;
			var rows:Number = 2;
			
			var time1:Number =  getTimer();
			var bitmapDataTiles = TileMaker.makeTiles(goat, cols, rows);
			var time2:Number = getTimer();
			
		
			
			//for layout display
			var tileW:Number = goat.width / (cols);
			var tileH:Number = goat.height / (rows);			
			var spacer:Number = 10;
			var yOffset:Number = 10;			
			var xOffset:Number = 10;			
			var bitmapTiles:Array = new Array() ;
			for (var yi:Number = 0; yi < rows; yi++)
			{
				for (var xi:Number = 0; xi < cols; xi++)
				{
					var index:Number = xi + ((cols) * yi);
					Logger.debug("imageCroptest index: = " + index);
					var bitmapTile:Bitmap = new Bitmap(bitmapDataTiles[index]);
					bitmapTile.y = yOffset  + (yi * (tileH+ spacer));
					bitmapTile.x = yOffset + ( xi * (tileW + spacer));
					addChild(bitmapTile);
					//bitmapTiles.push(bitmapTile);
 				}
			}
			
			
			//var testTile:Bitmap = bitmapTiles[3];
			//addChild(testTile);
			//testTile.x = 500;
			//testTile.y = 100;
			
			
		}
		
		

		
	}

}